﻿#ifndef TEXTEDIT_H
#define TEXTEDIT_H

#include "qsendfiledialog.h"
#include <QQueue>
#include <QTextEdit>
#include <QObject>
#include <QWidget>
#include <QFile>
#include <QFileInfo>
#include <QMimeData>
#include <QTextImageFormat>
#include <QTextFrameFormat>
#include <QTextCursor>
#include <QMouseEvent>
#include <QTextBlock>
#include <QUuid>
#include <QImageReader>

class TextEdit : public QTextEdit
{
    Q_OBJECT
public:
    TextEdit(QWidget *parent = nullptr);
    void insertFile(const QString &filePath);
signals:
    void upLoadFile(const QString &filePath);
protected:
    bool canInsertFromMimeData(const QMimeData *source) const;
    void insertFromMimeData(const QMimeData *source) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseDoubleClickEvent(QMouseEvent *event) override;
private:
    QSize scaleImageSize(const QString &imagePath);
//    void dropImage(const QUrl &url, const QImage &image);
    void dropTextFile(const QUrl &url);

};

#endif // TEXTEDIT_H
